import { _decorator, Component, director, EventTouch, find, Label, native, Node } from 'cc';
import { UIManager } from './UIManager';
import { AudioManager } from './AudioManager';
import Banner, { BannerMode } from './Banner';
import { BundleManager } from './BundleManager';
import { GameManager } from './GameManager';
import { EventManager, IncidentEvent } from './EventManager';
import { MyEvent } from './Controller/EventController';
import { BannerManager } from './BannerManager';
const { ccclass, property } = _decorator;



@ccclass('MainPanel')
export class MainPanel extends Component {
    public static IsOnce: boolean = true;
    @property(Node)
    Canvas: Node = null;
    @property(Node)
    PrivacyPanel: Node = null;
    protected start(): void {


        if (MainPanel.IsOnce) {//第一次
            AudioManager.Init();
            MainPanel.IsOnce = false;
            BannerManager.Instance.Init();
        } else {//后续

        }
        if (Banner.IS_ANDROID && !(Banner.Mode == BannerMode.测试包)) {
            var result = native.reflection.callStaticMethod("com/cocos/game/MainActivity", "Judgechannel", "()Ljava/lang/String;");
            switch (result) {
                case "VivoBtn":
                    find("Canvas/联系客服").active = true;
                    break;
                case "OppoBtn":
                    find("Canvas/联系客服").active = true;
                    find("Canvas/更多精彩").active = true;
                    break;
                case "HuaweiBtn":
                    find("Canvas/注销账号").active = true;
                    break;
            }
        }


    }


    //按钮事件
    OnButtonClick(btn: EventTouch) {
        switch (btn.target.name) {
            case "开始游戏":
                UIManager.GoScene("Game");
                break;
            case "隐私政策":
                if (Banner.IS_ANDROID) {
                    Banner.Instance.AndroidPrivacy();
                } else {
                    //展示隐私界面
                    this.PrivacyPanel.active = true;
                    this.PrivacyPanel.getChildByName("ScrollView").getChildByName("view").getChildByName("content").getChildByName("PrivacyLabel")
                        .getComponent(Label).string = BundleManager.PrivacyText;
                }
                break;
            case "关闭隐私":
                this.PrivacyPanel.active = false;
                break;
            case "联系客服":
                Banner.Instance.AndroidKeFu();
                break;
            case "更多精彩":
                Banner.Instance.AndroidMoreGame();
                break;
        }


    }



}


